package com.chixing.controller;

import com.chixing.Server.CameraServer;
import com.chixing.pojo.Camera;
import com.chixing.pojo.Result;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/camera")
public class CameraController {
    @Autowired
    private CameraServer cameraServer;
    @GetMapping("/queryById")
    public Result queryById(@Param("id") String id)
    {
        Camera camera = cameraServer.queryById(id);
        if(camera != null)
        {
            return Result.success(camera);
        }
        return Result.error("查询失败");
    }
    @GetMapping("/queryByBrandPage")
    public Result queryByBrandPage(@Param("brand") String brand,@Param("start") int start,@Param("pageSize") int pageSize)
    {
        return Result.success(cameraServer.queryByBrandPage(brand,start,pageSize));
    }

    @GetMapping("/queryAllByLimit")
    public Result queryAllByLimit(@Param("start") int start,@Param("pageSize") int pageSize)
    {
        return Result.success(cameraServer.queryAllByLimit(start,pageSize));
    }
    @GetMapping("/queryListByName")
    public Result queryListByName(@Param("name") String name)
    {
        return Result.success(cameraServer.queryListByName(name));
    }

}
